<extend name="Include:Layout"/>
<block name="title">签到列表</block>
<block name="style">
<style>
.desc {    color: #999;
    font-size: 13px;
    line-height: 1.2;}
</style>
</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_tab_bd container" id="container">
			<div class="weui_tab">
		        <div class="weui_navbar">
	            	<div class="toolbar">
				        <div class="toolbar-inner">
				            <a href="{:U('signedit',array('lid'=>$_GET['lid']))}" class="picker-button close-popup">添加</a>
				            <h1 class="title" id="banji_title">签到列表</h1>
				        </div>
				    </div>
		        </div>
		        <div class="weui_tab_bd" id="content" style="margin-top:0px;">
					<div id="data-content" data-page="1"></div>
					<div class="weui-infinite-scroll" id='infinite'>
						<div class="infinite-preloader"></div>
						  正在加载...
					</div>
				</div>
		    </div>
	    </div>
		
    </div>

<script id="data-tpl" type="text/html">
<div class="weui_panel">
    <div class="weui_panel_bd">
        <a href="/home/my/signedit/id/{{id}}" style="display:block" class="weui_media_box weui_media_text">
            <h4 class="weui_media_title">{{title}}</h4>
			{{if daoname}}
            <div class="desc weui-row">
				<div class="weui-col-20">到场：</div>
				<div class="weui-col-80">{{#daoname | decodehtmljson:daoname}}</div>
            </div>
			{{/if}}
			{{if qingjianame}}
 			<div class="desc weui-row">
				<div class="weui-col-20">请假：</div>
				<div class="weui-col-80">{{#qingjianame | decodehtmljson:qingjianame}}</div>
            </div>
			{{/if}}
        </a>
    </div>
</div>
</script>
</block>

<block name="script">
<script>
$(document.body).infinite();
var loading = false;  //状态标记
$("#content").infinite().on("infinite", function() {
	//console.log("aa");
  if(loading) return;
  loading = true;
  load();
});
template.helper('decodehtmljson', function (str) {
	str = str.replace(new RegExp(/(\/\/&quot;)/g),'');
	str = str.replace(/&amp;/gi, '&');
	str = str.replace(/&nbsp;/gi, ' ');
	str = str.replace(/&quot;/gi, '"');
	str = str.replace(/&#39;/g, "'");
	str = str.replace(/&lt;/gi, '<');
	str = str.replace(/&gt;/gi, '>');
	//str = str.replace(/<br[^>]*>(?:(rn)|r|n)?/gi, '');
	return str;
});
$(function () {
	//第一次加载数据
	load();
});

function load(){
	//$.showLoading("正在加载...");
	 var lid = {$_GET['lid']};
	 var page=$("#data-content").attr("data-page");
	 setTimeout(function() {
		 $.get('/home/my/getsigninfo',{lid:lid,page:page},function(ret){
				var html = '' ;
				var tmp = ret.info;
				for(var i = 0 ; i <tmp.length ; i++){
					html += template('data-tpl',tmp[i]);
				}
				var p = parseInt(page)+1;
				$('#data-content').append(html).attr("data-page",p);
				//$.hideLoading();
				$("#content").pullToRefreshDone();
				loading = false;
				if(ret.next == 'no'){
					$("#content").destroyInfinite();
					$("#infinite").hide();
				}
			}); 
	 },300);
}
</script>
</block>